﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TimeTracker_Entities;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;

namespace TimeTracker.Models
{
    public class ClientModel
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ClientModel"/> class.
        /// </summary>
        /// <param name="entity">The entity containing data for initializing the model.</param>
        public ClientModel(Client entity)
        {
            ClientId = entity.ClientId;
            ClientName = entity.ClientName;
            HourlyBillingRate = entity.HourlyBillingRate;
            BillingTermsId = entity.BillingTermsId;
            BillingTermsDescription = entity.BillingTerm.BillingTermsDescription;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ClientModel"/> class.
        /// </summary>
        public ClientModel() { }

        /// <summary>
        /// Gets or sets the client id corresponding to the <see cref="ClientModel"/>.
        /// </summary>
        /// <value>The client id.</value>
        public int ClientId { get; set; }

        /// <summary>
        /// Gets or sets the name of the client.
        /// </summary>
        /// <value>The name of the client.</value>
        [Required]
        public string ClientName { get; set; }

        /// <summary>
        /// Gets or sets the hourly billing rate corresponding to the <see cref="ClientModel"/>.
        /// </summary>
        /// <value>The hourly billing rate.</value>
        [Required]
        [UIHint("Currency")]
        [DefaultValue(75.0)]
        [DisplayFormat(DataFormatString="{0:c}")]
        public decimal HourlyBillingRate { get; set; }

        /// <summary>
        /// Gets or sets the billing terms id corresponding to the <see cref="ClientModel"/>.
        /// </summary>
        /// <value>The billing terms id.</value>
        [UIHint("BillingTerms")]
        [Required]
        public int? BillingTermsId { get; set; }

        /// <summary>
        /// Gets or sets the billing terms description corresponding to the <see cref="ClientModel"/>.
        /// </summary>
        /// <value>The billing terms description.</value>
        public string BillingTermsDescription { get; set; }
    }
}